home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / dobbs / v16n11 / portunix.asc < prev    next >
Encoding:
Text File  |  1991-11-15  |  861 b   |  53 lines

  1. _PORTING UNIX APPLICATIONS TO DOS_
  2. by David N. Glass
  3.  
  4.  
  5. Figure 1: Macros to handle text and binary files in DOS.
  6.  
  7. #ifdef DOS
  8. #    define READ_BIN    "rb"
  9. #    define READ_TXT    "r"
  10. #    define WRITE_BIN "wb"
  11. #    define WRITE_TXT "w"
  12. #else    /* the unix way */
  13. #    define READ_BIN    "r"
  14. #    define READ_TXT    "r"
  15. #    define WRITE_BIN "w"
  16. #    define WRITE_TXT    
  17. #endif     /* DOS */
  18.  
  19.  
  20.  
  21. Figure 2:  Mapping the UNIX SIGALRM to a DOS user-defined signal.
  22.  
  23. #ifdef DOS
  24. # define SIGALRM SIGUSR1
  25. #endif     /*DOS*/
  26.  
  27.  
  28.  
  29.  
  30. Figure 3. Writing files using a specified file handle.
  31.  
  32. write_files(fp, buffer, bytes)
  33. int fp;
  34. char *buffer;
  35. int bytes;
  36. {
  37.   if (bytes > 0) write(fp, buffer, bytes);
  38. }
  39.  
  40.  
  41.  
  42. Figure 4: Mapping WRIT_TTY to either DOS or UNIX I/O calls.
  43.  
  44. #ifdef DOS
  45. # define WRITE_TTY write_port
  46. #else  /* unix */
  47. # define WRITE_TTY write
  48. #endif    /* DOS */
  49.  
  50.  
  51.  
  52.  
  53.